function dragline()
myfh=figure;
myaxes=axes('position',[0 0 1 1],'color','k');
r = randi(100,1,25);
r2 = randi(10,25,1);r2=r2';
% r3= ones(1,25);
x1= 1:4:100 ;
plot(x1,r,x1,r2);
y_lim=ylim(myaxes);
x0=1;
% xline = line([x0 x0],y_lim,'Color','r','EraseMode','xor','tag','xhvl');
historyCursor = cursors(myaxes,'r');
addlistener(historyCursor,'onStartDrag',@myevent_cursor_onStartDrag);
addlistener(historyCursor,'onDrag'     ,@myevent_cursor_onDrag);
addlistener(historyCursor,'onReleased' ,@myevent_cursor_onReleased);
assignin('base','historyCursor', historyCursor);

      CminValue = x1(ceil(end/4));
      CmaxValue = x1(ceil(3*end/4));

      % Remove all cursors if exist
      if ~isempty(historyCursor.Positions)
        historyCursor.remove([]);
      end
      
      % Add cursors
      historyCursor.add(CmaxValue);
      historyCursor.newpos(10);
      


  function myevent_cursor_onStartDrag(eventSrc,eventData) 
    disp(' ')
    disp('Started Drag ');
    cursorPos = sort(eventData.Positions)';
    disp(['xstart = ' num2str(cursorPos')]);
  end

  function myevent_cursor_onDrag(eventSrc,eventData) 
%     disp('Dragging ');
%     cursorPos = sort(eventData.Positions)';
%     disp(cursorPos');
  end

  function myevent_cursor_onReleased(eventSrc,eventData) 
    cursorPos = sort(eventData.Positions)';
    disp(['xend = ' num2str(cursorPos')]);
    disp('Drag released ');
  end
end